package cn.qitom.auth.enpoint;


import cn.dev33.satoken.stp.SaTokenInfo;
import cn.dev33.satoken.stp.StpUtil;
import cn.qitom.auth.granter.CodeGranter;
import cn.qitom.auth.granter.GranterProp;
import cn.qitom.auth.granter.LegoGranterManager;
import cn.qitom.auth.model.LegoUserDetail;
import cn.qitom.core.auth.LegoUser;
import cn.qitom.core.auth.util.SecureUtil;
import cn.qitom.core.tool.api.R;
import cn.qitom.service.user.entity.UserBase;
import cn.qitom.service.user.feign.IUserClient;
import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;


@Slf4j
@RestController
@AllArgsConstructor
//@Api(value = "登录", tags = "登录校验")
public class LegoTokenEndPoint {

	private final IUserClient userClient;


	//@ApiLog("登录用户验证获取租户列表")
	@PostMapping("/oauth/user")
	//@ApiOperation(value = "登录用户验证获取租户列表", notes = "手机:phone,密码:password")
	public Object oauthUser(GranterProp prop,
						 HttpServletRequest request
	) throws Exception {
		return LegoGranterManager.route(prop).login();
	}


	@PostMapping("/user/isLogin")
	public Object isLogin(LegoUser legoUser
						  ) throws Exception {
		boolean login = StpUtil.isLogin();
		return R.ok(login);

	}

}
